<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>WebSocket测试</title>
    <script>
        var ws = new WebSocket('ws://127.0.0.1:8001/dcloud');
        ws.onopen = function() {
            console.log('WebSocket 连接已经建立。');
            ws.send('Hello, server!');
        };
        ws.onmessage = function(event) {
            console.log('收到服务器消息：', event.data);
        };
        ws.onerror = function(event) {
            console.error('WebSocket 连接出现错误：', event);
        };
        ws.onclose = function() {
            console.log('WebSocket 连接已经关闭。');
        };
        function sendMessage() {
            var message = document.getElementById('message').value;
            ws.send(message);
        }
    </script>
</head>
<body>
    <h1>WebSocket 测试</h1>
<div>
    <input type="text" id="message" placeholder="输入消息">
    <button onclick="sendMessage()">发送消息</button>
</div>


</body>
</html>